﻿namespace EyeOpen.Security.Server.BootStrapper
{
    using EyeOpen.Dependency;
    using EyeOpen.Security.Data.Nhibernate;
    using EyeOpen.Security.Service;
    using NHibernate;
                                                                                                      
    public class SecurityServiceFactory
    {
        public ISecurityServiceContext CreateServiceContext()
        {
            DependencyContainerService
                .Configure<SecurityContainerConfigurator>();

            var securityDataContext =
                DependencyContainerService
                    .Instance
                    .Resolve<ISessionFactory>(SecurityContainerConfigurator.SecurityConfigurationName);

            var securityServiceContext = new SecurityServiceContext(new NhibernateSecurityDataContext(securityDataContext.OpenSession()));
            return securityServiceContext;
        }                                         
    }
}
